
function getDaysFromPreviousYjqStartDate(detailXAxisDayStr){
   	
   		var previousYjqStartDateStr = getPreviousYjqStartDate(detailXAxisDayStr);
   		if(previousYjqStartDateStr == "NOT FOUND")
   			return 0;
   		
   		var detailXAxisDayArray = detailXAxisDayStr.split('-');   		
   		var yjqStartDateArray = previousYjqStartDateStr.split('-');
   		
   		//safari 只支持Y/M/D格式的New Date('Y/M/D');不能New Date('Y-M-D');
   		var detailXAxisDayObj = new Date(detailXAxisDayArray[0] + "/" + detailXAxisDayArray[1] + "/" + detailXAxisDayArray[2]);
   		var yjqStartDateObj = new Date(yjqStartDateArray[0] + "/" + yjqStartDateArray[1] + "/" + yjqStartDateArray[2]);
   		
   		var DaysFromPreviousYjqStartDate = parseInt((detailXAxisDayObj  -  yjqStartDateObj) / 1000 / 60 / 60 /24) + 1;   		
   		
   		if(DaysFromPreviousYjqStartDate > 0)
   			return DaysFromPreviousYjqStartDate;
   		else
   			return 0;
   }
   
   function getPreviousYjqStartDate(detailXAxisDayStr){
   		var previousYjqStartDateStr;
        var customerDataYjqStartDateArrayStr = localStorage.getItem("customerDataYjqStartDateArrayStrKey");
        customerDataYjqStartDateArray = customerDataYjqStartDateArrayStr.split(",");
   		var yjqStartDateArrayLen = customerDataYjqStartDateArray.length;
   		
   		var i;
   		for(i = yjqStartDateArrayLen - 1; i >= 0; i--){  			
   			if(compareDateStr(customerDataYjqStartDateArray[i], detailXAxisDayStr)){
   				previousYjqStartDateStr = customerDataYjqStartDateArray[i];
   				break;
   			}
   		}
   		
   		if(i == -1)
   			return "NOT FOUND";
   		else
   			return previousYjqStartDateStr;
   }
   
   function showPeriodDayStateDetail(detailXAxisDayStr){   		
   		showHeart(detailXAxisDayStr);
   		showMoon(detailXAxisDayStr);
   		showMedicine(detailXAxisDayStr);
   		showDrink(detailXAxisDayStr);
   		showPlane(detailXAxisDayStr);   		
   }
   
   function showHeart(detailXAxisDayStr){
   		var heart = customerDateHeartMap.get(detailXAxisDayStr);
   		
   		if(heart == "yes")
   			document.getElementById('heart').style.visibility="visible";  
   		else
   			document.getElementById('heart').style.visibility="hidden";  	
   }
   
   function showMoon(detailXAxisDayStr){
   		var moon = customerDateMoonMap.get(detailXAxisDayStr);
   		
   		if(moon == "yes")
   			document.getElementById('moon').style.visibility="visible";  
   		else
   			document.getElementById('moon').style.visibility="hidden";  	
   }
   
   function showMedicine(detailXAxisDayStr){
   		var medicine = customerDateMedicineMap.get(detailXAxisDayStr);
   		
   		if(medicine == "yes")
   			document.getElementById('medicine').style.visibility="visible";  
   		else
   			document.getElementById('medicine').style.visibility="hidden";  	
   }
   
   function showDrink(detailXAxisDayStr){
   		var drink = customerDateDrinkMap.get(detailXAxisDayStr);
   		
   		if(drink == "yes")
   			document.getElementById('drink').style.visibility="visible";  
   		else
   			document.getElementById('drink').style.visibility="hidden";   	
   }
   
   function showPlane(detailXAxisDayStr){
   		var plane = customerDatePlaneMap.get(detailXAxisDayStr);
   		
   		if(plane == "yes")
   			document.getElementById('plane').style.visibility="visible";  
   		else
   			document.getElementById('plane').style.visibility="hidden";   	
   }
   
   function getDetailDate(dateStr){
   		return getMonthStr(dateStr) + '月' + getDayStr(dateStr) + '日';
   }
   
   function getDetailDayOfWeek(dateStr){
   		return '星期' + getDayOfWeek(dateStr);
   }
   
   function getDayOfWeek(dateStr){
   		var dateArray = new Array();      
	    dateArray = dateStr.split('-');    
	    var dateObj =new Date(dateArray[0],parseInt(dateArray[1]-1),dateArray[2]);   
	    return getNumberToChinese(dateObj.getDay());
   }

	function getNumberToChinese(num){
		var chineseDayOfWeek;
		switch(num){
			case 1:
				chineseDayOfWeek = "一";
				break;
			case 2:
				chineseDayOfWeek = "二";
				break;
			case 3:
				chineseDayOfWeek = "三";
				break;
			case 4:
				chineseDayOfWeek = "四";
				break;
			case 5:
				chineseDayOfWeek = "五";
				break;
			case 6:
				chineseDayOfWeek = "六";
				break;
			case 0:
				chineseDayOfWeek = "天";
				break;			
		}
		return chineseDayOfWeek;
	}
  
  	function setPeriodImageSrc(periodTitle){
  		var imageDir = "img/period/";
  		var imgName;

  		if(periodTitle == periodYjq)
  			imgName = "yjq.png";
  		else if(periodTitle == periodPlq)
  			imgName = "plq.png";
  		else if(periodTitle == periodLpq)
  			imgName = "lpq.png";
  		else if(periodTitle == periodHtq)
  			imgName = "htq.png";
  		else
  			imgName = "unknown.png";
  			
  		return  (imageDir + imgName);		
  	}